package com.ymatou.iapi.optrade.testcase;

import java.math.BigDecimal;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.optrade.parameter.enums.LogisticsTypeEnum;
import com.ymatou.iapi.optrade.parameter.req.AcceptOrderReq;
import com.ymatou.iapi.optrade.parameter.utill.Utils;
import com.ymatou.iapi.optrade.resp.TradingServiceResp;
import com.ymatou.iapi.optrade.service.BargainGroupService;
import com.ymatou.iapi.optrade.service.IdCardService;
import com.ymatou.iapi.optrade.service.SellerAcceptOrderCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymt.utils.tag.P3;
import com.ymttest.business.service.YMTTrading.TradingCallService;
import com.ymttest.business.service.YMTTrading.TradingPlaceOrderCallService;
import com.ymttest.database.sharding.db.sharding.model.OrderPo;
import com.ymttest.database.sharding.db.sharding.model.OrderStatusLogPo;
import com.ymttest.database.sharding.db.sqlwapper.OrderShardingWapper;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.constant.ECode;

public class Ts_SellerAcceptOrder {
	
	private static AcceptOrderReq acceptorderbean;
	private static SellerAcceptOrderCall acceptordercall;

	private static OrderShardingWapper database = new OrderShardingWapper();

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("卖家接单");
	}

	@Before
	public void caseUp() {
		acceptorderbean = new AcceptOrderReq();
		acceptordercall = new SellerAcceptOrderCall();

	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(acceptordercall.getOpurl());
		database.activeDeadCommunicationsLink(database);
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	/**
	 * 校验订单表状态，单主状态操作日志表
	 */
	public static void verifyOrderStatus(long orderId, long sellerId,
			boolean isAuto) {

		// 订单表(order)
		OrderPo ymtOrders = database.selectOrderbyOrderId(orderId);
		
		

		Logger.comment(String.format("验证订单表(order)表 orderId: %s", orderId));

		Logger.verifyEquals(17, ymtOrders.getOrderStatus(), "验证orderStatus");

		// 订单主状态操作日志表(order_status_log)
		OrderStatusLogPo orderStatusLogPo = database
				.selectOrderStatusLogByOrderId(orderId);

		Logger.comment("验证订单主状态操作日志表(order_status_log)");

		String memo = "接单";

		if (isAuto) {
			memo = "系统自动接单";
		}
		
		if (ymtOrders.getSalesman() > 0 && acceptorderbean.getCsId() != 0)
			memo = String.format("客服【 %s】接单", acceptorderbean.getCsId());

		Logger.verifyEquals(memo, orderStatusLogPo.getMemo(), "验证数据库Memo");

		Logger.verifyEquals(17, orderStatusLogPo.getOrderStatus(),
				"验证数据库OrderStatus");

		Logger.verifyEquals(true,
				Utils.calcTimeSpanMin(orderStatusLogPo.getAddTime()) < 2,
				"验证数据库AddTime跟系统当前时间差为2分钟内");

		Logger.verifyEquals(orderId, orderStatusLogPo.getOrderId(),
				"验证数据库OrderId");
		Logger.verifyEquals(sellerId, orderStatusLogPo.getOperator(),
				"验证数据库Operator");

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_SellerAcceptOrder_001() {
		Logger.start(true, "卖家接单成功");
		try {
			// 创建订单
			Logger.comment("准备前置数据");

			TradingServiceResp placeOrderResp = TradingCallService.payOrder();

			OrderPo order = placeOrderResp.getOrderList().get(0).getOrderPo();

			long orderId = order.getOrderId();

			long sellerId = order.getSellerId();

			Logger.comment("前置数据准备结束");

			// 接单
			acceptorderbean.setOrderId(orderId);// 订单ID
			acceptorderbean.setSellerId(sellerId);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();

			Logger.verifyEquals(Integer.valueOf(ECode.SUCCESS),
					acceptordercall.getCode(), "验证Code");
			// 数据库验证
			verifyOrderStatus(orderId, sellerId, false);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_SellerAcceptOrder_002() {
		Logger.start(false, "订单不存在，卖家接单失败");
		try {
			Integer OrderId = 1048827;
			int SellerId = 288484;
			// 接单
			acceptorderbean.setOrderId(OrderId);// 订单ID
			Logger.comment("SellerId:" + SellerId);
			acceptorderbean.setSellerId(SellerId);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();
			Logger.verifyEquals(Integer.valueOf(ECode.FAILED201),
					acceptordercall.getCode(), "验证Code");
			Logger.verifyEquals("订单号" + OrderId + "不存在",
					acceptordercall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_SellerAcceptOrder_003() {
		Logger.start(false, "订单为非支付成功状态，卖家接单失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithLogisticsType(LogisticsTypeEnum.OVERSEAS_DELIVERY);
			
			OrderPo order = placeOrderResp.getOrderList().get(0).getOrderPo();

			long orderId = order.getOrderId();

			long sellerId = order.getSellerId();

			Logger.comment("前置数据准备结束");
			// 接单
			acceptorderbean.setOrderId(orderId);// 订单ID
			acceptorderbean.setSellerId(sellerId);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();

			Logger.verifyEquals(201, acceptordercall.getCode(), "验证Code");

			Logger.verifyEquals(102, acceptordercall.getBCode(), "验证bcode");

			Logger.verifyEquals(String.format("当前订单[%s]状态不能确认接单", orderId),
					acceptordercall.getMsg(), "验证Msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_SellerAcceptOrder_004() {
		Logger.start(false, "卖家重复接单");
		try {
			// 创建订单
			Logger.comment("准备前置数据");

			TradingServiceResp placeOrderResp = TradingCallService
					.orderAccept();

			OrderPo order = placeOrderResp.getOrderList().get(0).getOrderPo();

			long orderId = order.getOrderId();

			long sellerId = order.getSellerId();

			Logger.comment("前置数据准备结束");
			// 接单
			acceptorderbean.setOrderId(orderId);// 订单ID
			acceptorderbean.setSellerId(sellerId);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();

			Logger.verifyEquals(200, acceptordercall.getCode(), "验证Code");
			// 数据库验证
			verifyOrderStatus(orderId, sellerId, false);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_SellerAcceptOrder_005() {
		Logger.start(false, "卖家用户id不是订单的卖家");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			TradingServiceResp placeOrderResp = TradingCallService.payOrder();

			OrderPo order = placeOrderResp.getOrderList().get(0).getOrderPo();

			long orderId = order.getOrderId();

			long sellerId = order.getSellerId();

			Logger.comment("前置数据准备结束");
			// 接单
			acceptorderbean.setOrderId(orderId);// 订单ID
			acceptorderbean.setSellerId(sellerId + 1);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();
			Logger.verifyEquals(201, acceptordercall.getCode(),
					"验证Code");
			Logger.verifyEquals("用户" + acceptorderbean.getSellerId() + "不是订单"
					+ acceptorderbean.getOrderId() + "的所有者",
					acceptordercall.getMsg(), "验证Msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_SellerAcceptOrder_006() {
		Logger.start(false, "卖家用户id为null");
		try {
			// 接单
			acceptorderbean.setOrderId(1111);// 订单ID
			// acceptorderbean.setSellerId(sellerId+1);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();
			Logger.verifyEquals(201, acceptordercall.getCode(),
					"验证Code");
			Logger.verifyEquals("订单号" + acceptorderbean.getOrderId() + "不存在",
					acceptordercall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_SellerAcceptOrder_007() {
		Logger.start(false, "订单id为null");
		try {
			// 接单
			// acceptorderbean.setOrderId(orderId);// 订单ID
			acceptorderbean.setSellerId(1113);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();
			Logger.comment("卖家重复接单");
			acceptordercall.callService();
			Logger.verifyEquals(400, acceptordercall.getCode(),
					"验证Code");
			Logger.verifyIsContains("订单号不能为空", acceptordercall.getMsg(),
					"验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SellerAcceptOrder_008() {
		Logger.start(false, "订单为风控不通过状态");
		try {
			// 创建订单
			Logger.comment("准备前置数据");

			TradingServiceResp placeOrderResp = TradingCallService.payOrder();

			OrderPo order = placeOrderResp.getOrderList().get(0).getOrderPo();

			long orderId = order.getOrderId();

			long sellerId = order.getSellerId();

			OrderPo record = database.selectOrderbyOrderId(orderId);

			record.setRiskStatus(1);

			// 修改订单表
			database.clearCache();
			database.orderMapper.updateByPrimaryKey(record);

			Logger.comment("前置数据准备结束");
			// 接单
			acceptorderbean.setOrderId(orderId);// 订单ID
			acceptorderbean.setSellerId(sellerId);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();

			Logger.verifyEquals(Integer.valueOf(ECode.FAILED201),
					acceptordercall.getCode(), "验证Code");

			Logger.verifyEquals(105, acceptordercall.getBCode(), "验证bcode");

			Logger.verifyEquals(String.format("当前订单[%s]不能确认接单-风控审核中", orderId),
					acceptordercall.getMsg(), "验证Msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SellerAcceptOrder_009() {
		Logger.start(false, "订单风控通过状态");
		try {
			// 创建订单
			Logger.comment("准备前置数据");
			TradingServiceResp placeOrderResp = TradingCallService.payOrder();

			OrderPo order = placeOrderResp.getOrderList().get(0).getOrderPo();

			long orderId = order.getOrderId();

			long sellerId = order.getSellerId();
			OrderPo record = database.selectOrderbyOrderId(orderId);

			record.setRiskStatus(2);

			// 修改订单表
			database.clearCache();
			database.orderMapper.updateByPrimaryKey(record);
			Logger.comment("前置数据准备结束");
			// 接单
			acceptorderbean.setOrderId(orderId);// 订单ID
			acceptorderbean.setSellerId(sellerId);// 卖家ID

			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();
			Logger.verifyEquals(200, acceptordercall.getCode(),
					"验证Code");
			// 数据库验证

			verifyOrderStatus(orderId, sellerId, false);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_SellerAcceptOrder_010() {
		Logger.start(false, "订单风控检测失败状态");
		try {
			// 创建订单
			Logger.comment("准备前置数据");
			TradingServiceResp placeOrderResp = TradingCallService.payOrder();

			OrderPo order = placeOrderResp.getOrderList().get(0).getOrderPo();

			long orderId = order.getOrderId();

			long sellerId = order.getSellerId();

			OrderPo record = database.selectOrderbyOrderId(orderId);

			record.setRiskStatus(3);

			// 修改订单表
			database.clearCache();
			database.orderMapper.updateByPrimaryKey(record);
			Logger.comment("前置数据准备结束");
			// 接单
			acceptorderbean.setOrderId(orderId);// 订单ID
			acceptorderbean.setSellerId(sellerId);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();
			Logger.verifyEquals(200, acceptordercall.getCode(),
					"验证Code");

			verifyOrderStatus(orderId, sellerId, false);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_SellerAcceptOrder_011() {
		Logger.start(true, "砍价团订单支付成功后,砍价团服务通知交易组团成功,商家接单成功.");
		try {
			// 创建订单
			Logger.comment("准备前置数据");

			String bizId = TestDataManager.getRandomNum(9);

			TradingServiceResp placeOrderResp = BargainGroupService
					.openGroup(bizId);
			// 砍价团id
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long orderId1 = placeOrderResp.getOrderList().get(0).getOrderId();

			BargainGroupService.notifyOrderBizStatus(bizId, orderId1, 1, 3);

			Logger.comment("前置数据准备结束");
			// 接单
			acceptorderbean.setOrderId(orderId1);// 订单ID
			acceptorderbean.setSellerId(sellerId);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();
			Logger.verifyEquals(200, acceptordercall.getCode(),
					"验证Code");

			// 数据库验证
			verifyOrderStatus(orderId1, sellerId, false);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_SellerAcceptOrder_012() {
		Logger.start(false, "砍价团订单支付成功后,砍价团服务通知交易成团消息之前,商家不允许接单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			String bizId = TestDataManager.getRandomNum(9);

			TradingServiceResp placeOrderResp = BargainGroupService
					.openGroup(bizId);
			// 砍价团id
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long orderId1 = placeOrderResp.getOrderList().get(0).getOrderId();

			Logger.comment("前置数据准备结束");
			// 接单
			acceptorderbean.setOrderId(orderId1);// 订单ID
			acceptorderbean.setSellerId(sellerId);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();

			Logger.verifyEquals(201, acceptordercall.getCode(),
					"验证code");
			Logger.verifyEquals(105, acceptordercall.getBCode(), "验证bcode");
			Logger.verifyEquals("砍价团订单在成团前不能确认接单", acceptordercall.getMsg(),
					"验证Msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_SellerAcceptOrder_013() {
		Logger.start(false, "砍价团订单支付成功后,砍价团服务通知交易开团成功,商家不允许接单.");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			String bizId = TestDataManager.getRandomNum(9);

			TradingServiceResp placeOrderResp = BargainGroupService
					.openGroup(bizId);
			// 砍价团id
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long orderId1 = placeOrderResp.getOrderList().get(0).getOrderId();

			BargainGroupService.notifyOrderBizStatus(bizId, orderId1, 1, 1);

			Logger.comment("前置数据准备结束");
			// 接单
			acceptorderbean.setOrderId(orderId1);// 订单ID
			acceptorderbean.setSellerId(sellerId);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();
			Logger.verifyEquals(201, acceptordercall.getCode(),
					"验证code");
			Logger.verifyEquals(105, acceptordercall.getBCode(), "验证bcode");
			Logger.verifyEquals("砍价团订单在成团前不能确认接单", acceptordercall.getMsg(),
					"验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_SellerAcceptOrder_014() {
		Logger.start(false, "砍价团订单支付成功后,砍价团服务通知交易参团成功,商家不允许接单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			String bizId = TestDataManager.getRandomNum(9);

			TradingServiceResp placeOrderResp = BargainGroupService
					.openGroup(bizId);
			// 砍价团id
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long orderId1 = placeOrderResp.getOrderList().get(0).getOrderId();

			// 参团
			TradingServiceResp placeOrderResp2 = BargainGroupService
					.joinGroup(bizId);

			long orderId2 = placeOrderResp2.getOrderList().get(0).getOrderId();

			BargainGroupService.notifyOrderBizStatus(bizId, orderId2, 2, 2);

			Logger.comment("前置数据准备结束");
			// 接单
			acceptorderbean.setOrderId(orderId1);// 订单ID
			acceptorderbean.setSellerId(sellerId);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();
			Logger.verifyEquals(201, acceptordercall.getCode(),
					"验证code");
			Logger.verifyEquals(105, acceptordercall.getBCode(), "验证bcode");

			Logger.verifyEquals("砍价团订单在成团前不能确认接单", acceptordercall.getMsg(),
					"验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_SellerAcceptOrder_015() {
		Logger.start(true,
				"贝海直邮商品订单电商件,订单收件人,订单金额不超过2000，但年消费额度超过20000,订单卖家接单失败.");
		try {
			// 创建订单
			Logger.comment("准备前置数据");

			String recvName = IdCardService.Idcard_Cost_User;
			;

			TradingServiceResp placeOrderResp = IdCardService.placeOrder(
					recvName, LogisticsTypeEnum.BondedDelivery, true,
					new BigDecimal(100));

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long userId = placeOrderResp.getUserId();
			long tradingId = placeOrderResp.getTradingId();

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();

			// 支付订单
			TradingCallService.payOrder(userId, useAccountAmount, tradingId,
					"13");

			IdCardService.updateIdcardCost(userId, recvName, new BigDecimal(
					20000));

			Thread.sleep(2000);

			Logger.comment("前置数据准备结束");
			// 接单
			acceptorderbean.setOrderId(orderId);// 订单ID
			acceptorderbean.setSellerId(sellerId);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();
			Logger.verifyEquals(201, acceptordercall.getCode(),
					"验证Code");
			Logger.verifyEquals(105, acceptordercall.getBCode(), "验证bcode");

			Logger.verifyEquals("该收件人已经超过20000限额,请联系买家修改收件人信息后重新接单.",
					acceptordercall.getMsg(), "验证bcode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_SellerAcceptOrder_016() {
		Logger.start(true, "贝海直邮商品个人件,订单收件人,订单金额不超过2000，但年消费额度超过20000,订单卖家接单成功");
		try {
			// 创建订单
			Logger.comment("准备前置数据");

			String recvName = IdCardService.Idcard_Cost_User;
			;

			TradingServiceResp placeOrderResp = IdCardService.placeOrder(
					recvName, LogisticsTypeEnum.BondedDelivery, false,
					new BigDecimal(100));

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long userId = placeOrderResp.getUserId();
			long tradingId = placeOrderResp.getTradingId();

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();

			// 支付订单
			TradingCallService.payOrder(userId, useAccountAmount, tradingId,
					"13");

			IdCardService.updateIdcardCost(userId, recvName, new BigDecimal(
					20000));

			Thread.sleep(2000);

			Logger.comment("前置数据准备结束");
			// 接单
			acceptorderbean.setOrderId(orderId);// 订单ID
			acceptorderbean.setSellerId(sellerId);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();
			Logger.verifyEquals(200, acceptordercall.getCode(),
					"验证Code");
			// 数据库验证
			verifyOrderStatus(orderId, sellerId, false);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_SellerAcceptOrder_017() {
		Logger.start(true, "贝海直邮商品订单,订单收件人,订单金额超过2000，年消费额度超过20000,卖家正常接单.");
		try {
			// 创建订单
			Logger.comment("准备前置数据");

			String recvName = IdCardService.Idcard_Cost_User;
			;

			TradingServiceResp placeOrderResp = IdCardService.placeOrder(
					recvName, LogisticsTypeEnum.BondedDelivery, false,
					new BigDecimal(2001));

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long userId = placeOrderResp.getUserId();
			long tradingId = placeOrderResp.getTradingId();

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();

			// 支付订单
			TradingCallService.payOrder(userId, useAccountAmount, tradingId,
					"13");

			IdCardService.updateIdcardCost(userId, recvName, new BigDecimal(
					20000));

			Logger.comment("前置数据准备结束");
			// 接单
			acceptorderbean.setOrderId(orderId);// 订单ID
			acceptorderbean.setSellerId(sellerId);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();
			Logger.verifyEquals(200, acceptordercall.getCode(),
					"验证Code");
			// 数据库验证
			verifyOrderStatus(orderId, sellerId, false);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_SellerAcceptOrder_018() {
		Logger.start(true, "非贝海直邮商品订单,订单收件人,订单金额不超过2000，年消费额度超过20000,卖家正常接单.");
		try {
			// 创建订单
			Logger.comment("准备前置数据");

			String recvName = IdCardService.Idcard_Cost_User;
			;

			TradingServiceResp placeOrderResp = IdCardService.placeOrder(
					recvName, LogisticsTypeEnum.OVERSEAS_DELIVERY, false,
					new BigDecimal(100));

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long userId = placeOrderResp.getUserId();
			long tradingId = placeOrderResp.getTradingId();

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();

			// 支付订单
			TradingCallService.payOrder(userId, useAccountAmount, tradingId,
					"13");

			IdCardService.updateIdcardCost(userId, recvName, new BigDecimal(
					20000));

			Logger.comment("前置数据准备结束");
			// 接单
			acceptorderbean.setOrderId(orderId);// 订单ID
			acceptorderbean.setSellerId(sellerId);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();
			Logger.verifyEquals(200, acceptordercall.getCode(),
					"验证Code");
			// 数据库验证
			verifyOrderStatus(orderId, sellerId, false);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_SellerAcceptOrder_019() {
		Logger.start(true, "非贝海直邮商品订单,订单收件人,订单金额超过2000，年消费额度超过20000,卖家正常接单.");
		try {
			// 创建订单
			Logger.comment("准备前置数据");

			String recvName = IdCardService.Idcard_Cost_User;
			;

			TradingServiceResp placeOrderResp = IdCardService.placeOrder(
					recvName, LogisticsTypeEnum.OVERSEAS_DELIVERY, false,
					new BigDecimal(2001));

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long userId = placeOrderResp.getUserId();
			long tradingId = placeOrderResp.getTradingId();

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();

			// 支付订单
			TradingCallService.payOrder(userId, useAccountAmount, tradingId,
					"13");

			IdCardService.updateIdcardCost(userId, recvName, new BigDecimal(
					20000));

			Logger.comment("前置数据准备结束");
			// 接单
			acceptorderbean.setOrderId(orderId);// 订单ID
			acceptorderbean.setSellerId(sellerId);// 卖家ID
			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();
			Logger.verifyEquals(200, acceptordercall.getCode(),
					"验证Code");
			// 数据库验证
			verifyOrderStatus(orderId, sellerId, false);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_SellerAcceptOrder_020() {
		Logger.start(true, "虚拟商品订单支付成功后,商家接单成功.");
		try {
			// 创建订单
			Logger.comment("准备前置数据");

			TradingServiceResp placeOrderResp = BargainGroupService
					.placeVirtualProduct();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			long userId = placeOrderResp.getUserId();
			long tradingId = placeOrderResp.getTradingId();

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();

			// 支付订单
			TradingCallService.payOrder(userId, useAccountAmount, tradingId,
					"13");

			Logger.comment("前置数据准备结束");
			// 接单
			acceptorderbean.setOrderId(orderId);// 订单ID
			acceptorderbean.setSellerId(sellerId);// 卖家ID

			// 发送请求
			acceptordercall.setData(acceptorderbean);
			acceptordercall.callService();
			Logger.verifyEquals(200, acceptordercall.getCode(),
					"验证Code");
			// 数据库验证
			verifyOrderStatus(orderId, sellerId, false);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}
